<!--
 * @Description:: 育小帮科技有限公司
 * @Version: 1.0
 * @Author: smallWhite
 * @Date: 2023-02-14 11:29:12
 * @LastEditors: smallWhite
 * @LastEditTime: 2023-07-13 18:18:54
 * @FilePath: /chats_news2.0/src/components/modal/modal.vue
-->
<template>
  <!-- 组件开始 -->
  <el-dialog :title="title"
    :visible.sync="dialogVisible"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    :width="width"
    :fullscreen="true"
    :before-close="handleClose">
    <div
      class="modal_body">
      <slot></slot>
    </div>
    <!-- 组件按钮 -->
    <span
      v-if="cancelText || okText"
      slot="footer"
      class="dialog-footer">
      <el-button
        v-if="cancelText"
        @click="handleClose">{{
        cancelText
      }}</el-button>
      <el-button v-if="okText"
        type="primary"
        :disabled="loading"
        @click="handleSubmit"><i
          v-if="loading"
          class="el-icon-loading"></i>{{
        okText
      }}</el-button>
    </span>
  </el-dialog>
  <!-- 组件结束 -->
</template>

<script>
export default {
  name: 'Yxb3NewModal',
  props: {
    // 头部
    title: {
      type: String,
      default: ''
    },
    // 取消按钮文字
    cancelText: {
      type: String,
      default: '取 消'
    },
    // 确认按钮文字
    okText: {
      type: String,
      default: '确 定'
    },
    // 宽度
    width: {
      type: String,
      default: '560px'
    },
    // 显示隐藏
    dialogVisible: {
      type: Boolean,
      default: false
    },
    // 按钮loading
    loading: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
     
    }
  },
  watch: {
    // 监听按钮值得变化
    loading(newVal, oldPwd) {
      this.loading = newVal
    }
  },
  

  methods: {
    // 关闭方法
    handleClose() {
      this.$emit('cancel')
    },
    // 确定方法
    handleSubmit() {
      this.$emit('ok')
    }
  }
}
</script>

<style lang="scss" scoped>
.modal_body {
 padding: 0!important;
 margin: -60upx -40upx;
 background: #000000;
 color: #ffffff;
}
</style>
